package LeetCode;

import java.util.Arrays;

public class LC_462_MinimumMovestoEqualArrayElementsII {

    public static void main(String[] args) {

    }

    public class Solution {
        public int minMoves2(int[] nums) {
            Arrays.sort(nums);
            int sum = 0;
            int median = nums[nums.length / 2];
            for (int num : nums)
                sum += Math.abs(median - num);
            return sum;
        }

    }
}